Những câu hỏi liên quan
huỳnh duy cát
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 3 2021 lúc 19:53

a)

uses crt;

var i,n:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until n<100;

if n mod 2=0 then 

begin

for i:=0 to n do 

  if i mod 2=0 then write(i:4);

end

else writeln(n,' khong la so chan');

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
20 tháng 3 2021 lúc 19:53

b)

uses crt;

var i,n:integer;

begin

clrscr;

repeat

write('Nhap n='); readln(n);

until n<100;

if n mod 2=1 then 

begin

for i:=1 to n do 

  if i mod 2=1 then write(i:4);

end

else writeln(n,' khong la so le');

readln;

end.

Bình luận (0)
foxbi
Xem chi tiết
Thanh Phong (9A5)
18 tháng 3 2023 lúc 7:00

Uses crt;

var n,i,x,u: integer;

begin clrscr;

readln(n);

for i:=1 to n do begin

readln(x);

u:=u+x;

end;

writeln(u);

readln;

end.

Bình luận (0)
BOXWICKED
25 tháng 12 2023 lúc 16:54

program TongCacSoNguyen;

var
  N, i, soNguyen, tong: integer;

begin
  // Nhập số lượng N
  write('Nhap so luong N: ');
  readln(N);

  // Khởi tạo tổng
  tong := 0;

  // Nhập và tính tổng các số nguyên
  for i := 1 to N do
  begin
    write('Nhap so nguyen thu ', i, ': ');
    readln(soNguyen);
    tong := tong + soNguyen;
  end;

  // In ra màn hình tổng
  writeln('Tong cua cac so nguyen la: ', tong);

  readln;
end.

Bình luận (0)
Phan Thị Ka
Xem chi tiết
Minh Lệ
19 tháng 3 2023 lúc 22:40

Câu 1:

Program HOC24;

var i,p: integer;

t: longint;

begin

write('Nhap P: '); readln(p);

t:=0;

for i:=1 to p do if i mod 2<>0 then t:=t+i;

write('Tong cac so le la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:41

Câu 2:

Program HOC24;

var i,n: integer;

t: longint;

begin

write('Nhap N: '); readln(n);

t:=0;

for i:=1 to n do if i mod 2=0 then t:=t+i;

write('Tong cac so chan la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:42

Câu 3:

Program HOC24;

var i,t,n: integer;

begin

write('Nhap N: '); readln(n);

t:=0;

for i:=1 to n do if n mod i=0 then t:=t+i;

write('Tong cac uoc cua ',n,' la: ',t);

readln

end.

Bình luận (0)
nuinuini
Xem chi tiết
Hưng Quốc
Xem chi tiết
Thanh Phong (9A5)
31 tháng 3 2023 lúc 16:51

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
láobốlaos
31 tháng 3 2023 lúc 16:54

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
Nguyễn Hoàng Duy
2 tháng 4 2023 lúc 16:31

1.

program InDaySoTuNhien;
var n, i: integer;
begin
   write('Nhap so nguyen duong n: ');
   readln(n);

   writeln('Day so tu 1 den ', n, ' la:');
   for i := 1 to n do
      write(i, ' ');
end.

2.

program InSoChan;
var
   n, i: integer;
begin
   write('Nhap so nguyen n: ');
   readln(n);

   writeln('Cac so nguyen chan trong khoang tu 1 den ', n, ' la:');
   for i := 1 to n do
   begin
      if i mod 2 = 0 then
         write(i, ' ');
   end;
end.

Bình luận (0)
Lê Tâm Anh
Xem chi tiết
gấu béo
7 tháng 5 2023 lúc 19:20

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

Bình luận (0)
nông thị ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:41

uses crt;

var a:array[1..200]of integer;

n,i,k,t,t1:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

write('Nhap k='); readln(k);

t:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then t:=t+a[i];

t1:=0;

for i:=1 to n do 

  if a[i] mod k=0 then t1:=t1+a[i];

writeln('Tong cac phan tu le la: ',t);

writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);

readln;

end.

Bình luận (1)
nguyễn hoàng long
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 1 2022 lúc 22:00

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

int main()

{

cin>>n;

for (i=1; i<=n; i++)

{

cin>>a[i];

}

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

for (i=1; i<=n; i++) if (a[i]%3==0) dem++;

cout<<dem<<" ";

t1=0;

dem1=0;

for (i=1; i<=n; i++)

if (a[i]%2!=0)

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

for (i=1; i<=n; i++)

if (ktnt(a[i])==true) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
ngomanhcuong
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:25

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

for (i=1; i<=n; i++)

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}

Bình luận (0)